package day05.homework;

import java.util.Arrays;

public class ArrayDemo {
    public static void main(String[] args) {
        int[] arr = new int[]{2, 5, 8, 4, 6, 5};
        System.out.println("长度为：" + arr.length);//6
        System.out.println("第三个元素为：" + arr[2]);//8
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }

        int[] a = Arrays.copyOf(arr, arr.length);
        System.out.println("\n数组1：");
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i] + " ");
        }

        int[] b = Arrays.copyOf(arr, arr.length - 1);//截去末尾值
        System.out.println("\n数组2：");
        for (int i = 0; i < b.length; i++) {
            System.out.print(b[i] + " ");
        }

        int[] c = Arrays.copyOf(arr, arr.length + 1);//末尾补0
        System.out.println("\n数组3：");
        for (int i = 0; i < c.length; i++) {
            System.out.print(c[i] + " ");
        }
        System.out.println("\n数组3地址值：" + c);//地址值
    }
}
